﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="logger"
    targetNamespace="http://schema.alexwang.com/library/log/"
    elementFormDefault="qualified"
    xmlns="http://schema.alexwang.com/library/log/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="nlogger">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="fileLoggers" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="fileLogger" minOccurs="1" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="general">
                      <xs:sequence>
                        <xs:element name="logDir" minOccurs="1" maxOccurs="1" type="xs:string"/>
                        <xs:element name="fileExtension" minOccurs="0" maxOccurs="1" type="xs:string" default=".log"/>
                        <xs:element name="overrideIfExist" minOccurs="0" maxOccurs="1" type="xs:boolean" default="false"/>
                        <xs:element name="behavior" type="createFileBehavior" minOccurs="0" maxOccurs="1" default="ByDay"/>
                        <xs:element name="maxAchieveSize" type="xs:double" minOccurs="0" maxOccurs="1" default="0"/>
                      </xs:sequence>
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="consoleLogger" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:complexContent>
              <xs:extension base="general">
                <xs:sequence>
                  <xs:element name="foregroundColor" minOccurs="0" maxOccurs="1">
                    <xs:complexType>
                      <xs:all>
                        <xs:element name="debug" type="colorEnum" default="White" minOccurs="0"/>
                        <xs:element name="info" type="colorEnum" default="White" minOccurs="0"/>
                        <xs:element name="warn" type="colorEnum" default="Yellow" minOccurs="0"/>
                        <xs:element name="error" type="colorEnum" default="Green" minOccurs="0"/>
                        <xs:element name="fatal" type="colorEnum" default="Red" minOccurs="0"/>
                      </xs:all>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:extension>
            </xs:complexContent>
          </xs:complexType>
        </xs:element>
        <xs:element name="traceLogger" type="general" minOccurs="0" maxOccurs="1"/>
        <xs:element name="xmlLoggers" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="xmlLogger" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="general">
                      <xs:sequence>
                        <xs:element name="logDir" minOccurs="1" maxOccurs="1" type="xs:string"/>
                        <xs:element name="fileExtension" minOccurs="0" maxOccurs="1" type="xs:string" default=".xml"/>
                        <xs:element name="overrideIfExist" minOccurs="0" maxOccurs="1" type="xs:boolean" default="false"/>
                        <xs:element name="behavior" type="createFileBehavior" minOccurs="0" maxOccurs="1" default="ByDay"/>
                        <xs:element name="maxAchieveSize" type="xs:double" minOccurs="0" maxOccurs="1" default="0"/>
                      </xs:sequence>
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="mailLoggers" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="mailLogger" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="general">
                      <xs:sequence>
                        <xs:element name="from" minOccurs="1" maxOccurs="1">
                          <xs:complexType>
                            <xs:attribute name="address" type="xs:string" use="required"/>
                            <xs:attribute name="host" type="xs:string" use="required"/>
                            <xs:attribute name="port" type="xs:integer" use="optional" default="25"/>
                          </xs:complexType>
                        </xs:element>
                        <xs:element name="to" type="addressList" minOccurs="1" maxOccurs="1"/>
                        <xs:element name="cc" type="addressList" minOccurs="0" maxOccurs="1"/>
                        <xs:element name="credential" minOccurs="1" maxOccurs="1">
                          <xs:complexType>
                            <xs:attribute name="username" type="xs:string" use="required"/>
                            <xs:attribute name="password" type="xs:string" use="required"/>
                          </xs:complexType>
                        </xs:element>
                        <xs:element name="subject" type="xs:string" minOccurs="1" maxOccurs="1"/>
                        <xs:element name="isBodyHtml" type="xs:boolean" minOccurs="0" maxOccurs="1" default="false"/>
                        <xs:element name="priority" minOccurs="0" maxOccurs="1" default="Normal">
                          <xs:simpleType>
                            <xs:restriction base="xs:string">
                              <xs:enumeration value="High"/>
                              <xs:enumeration value="Low"/>
                              <xs:enumeration value="Normal"/>
                            </xs:restriction>
                          </xs:simpleType>
                        </xs:element>
                      </xs:sequence>
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="eventLogger" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:complexContent>
              <xs:extension base="general">
                <xs:sequence>
                  <xs:element name="account" minOccurs="0" maxOccurs="1">
                    <xs:complexType>
                      <xs:attribute name="userName" type="xs:string" use="optional"/>
                      <xs:attribute name="domain" type="xs:string" use="optional"/>
                      <xs:attribute name="password" type="xs:string" use="optional"/>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="host" type="xs:string" default="." use="optional"/>
                <xs:attribute name="logName" type="xs:string" default="Application" use="optional"/>
                <xs:attribute name="category" type="xs:int" default="0" use="optional"/>
                <xs:attribute name="eventSource" type="xs:string" use="required"/>
                <xs:attribute name="eventId" type="xs:int" use="required"/>
              </xs:extension>
            </xs:complexContent>
          </xs:complexType>
        </xs:element>
        <xs:element name="customLoggers" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="customLogger" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="general">
                      <xs:sequence>
                        <xs:element name="adapter" minOccurs="1" maxOccurs="1">
                          <xs:complexType>
                            <xs:attribute name="type" type="xs:string" use="required"/>
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>           
    </xs:complexType>    
  </xs:element>
  <xs:complexType name="general">
    <xs:sequence>
      <xs:element name="flushLevel" minOccurs="0" maxOccurs="1" default="DEBUG">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="DEBUG"/>
            <xs:enumeration value="INFO"/>
            <xs:enumeration value="WARN"/>
            <xs:enumeration value="ERROR"/>
            <xs:enumeration value="FATAL"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="template" minOccurs="0" maxOccurs="1">
        <xs:complexType>
          <xs:attribute name="type" use="optional" type="xs:string" default="Alex.Library.Log.DefaultTemplate,Alex.Library.Log"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required"/>
  </xs:complexType>
  <xs:complexType name="addressList">
    <xs:sequence>
      <xs:element name="address" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="createFileBehavior">
    <xs:restriction base="xs:string">
      <xs:enumeration value="ByDay"/>
      <xs:enumeration value="ByWeek"/>
      <xs:enumeration value="ByMonth"/>
      <xs:enumeration value="ByYear"/>
      <xs:enumeration value="ByFileSize"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="colorEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Black"/>
      <xs:enumeration value="DarkBlue"/>
      <xs:enumeration value="DarkGreen"/>
      <xs:enumeration value="DarkCyan"/>
      <xs:enumeration value="DarkRed"/>
      <xs:enumeration value="DarkMagenta"/>
      <xs:enumeration value="DarkYellow"/>
      <xs:enumeration value="Gray"/>
      <xs:enumeration value="DarkGray"/>
      <xs:enumeration value="Blue"/>
      <xs:enumeration value="Green"/>
      <xs:enumeration value="Cyan"/>
      <xs:enumeration value="Red"/>
      <xs:enumeration value="Magenta"/>
      <xs:enumeration value="Yellow"/>
      <xs:enumeration value="White"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>
